
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <Length.h>
#include <Volume.h>


USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Length)
{
	TEST(should be able to compare: 1 mile == 1760 yard)
	{
		ASSERT_EQ(Length(1, MILE), Length(1760, YARD));
	}

	TEST(should be able to compare: 1 yard == 3 feet)
	{
		ASSERT_TRUE(Length(1, YARD) == Length(3, FEET));
	}

	TEST(should be able to compare: 1 mile != 1761 yard)
	{
		ASSERT_TRUE(Length(1, MILE) != Length(1761, YARD));
	}

	TEST("should be able to compare: 1 mile + 1760 yard = 2 mile")
	{
		ASSERT_EQ(Length(2, MILE), (Length(1, MILE) + Length(1760, YARD)));
	}

	TEST(should be able to compare: 1 feet != 1 tbsp)
	{
        ASSERT_THROWS((Length(1, FEET) != Volume(1, TBSP)), int);
	}

	TEST(should not add different unit type together)
	{
        ASSERT_THROWS((Length(1, FEET) + Volume(1, TBSP)), int);
	}

	TEST(should not allow user to define a new unit)
	{
        UnitType    unitType;
        ASSERT_THROWS((Unit(33, unitType)), int);
	}
    TEST("1777 YARD format to string is: 1 MILE 17 YARD")
    {
        Length  length(1777, YARD);

        ASSERT_EQ(string("1 MILE 17 YARD"), length.formatToString());
    }
    TEST("0 YARD format to string is: 0 FEET")
    {
        Length  length(0, YARD);

        ASSERT_EQ(string("0 FEET"), length.formatToString());
    }
    TEST("1760*3+2 FEET format to string is: 1 MILE 2 FEET")
    {
        Length  length(1760*3+2, FEET);

        ASSERT_EQ(string("1 MILE 2 FEET"), length.formatToString());
    }
    TEST("3 YARD format to string in base unit is: 9 FEET")
    {
        Length  length(3, YARD);

        ASSERT_EQ(string("9 FEET"), length.formatToStringInBaseUnit());
    }
};


